@8wave/ai-elements 0.125.0-beta.42 → 0.125.0-beta.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/dist/_chunks/Chart-1vt0m6l_.js +87 -0
- package/dist/_chunks/Chart-1vt0m6l_.js.map +1 -0
- package/dist/_chunks/{PkChart-CbtMRGWc.js → PkChart-CYFx_UDq.js} +741 -623
- package/dist/_chunks/PkChart-CYFx_UDq.js.map +1 -0
- package/dist/_chunks/PkFilePreview-DfYzaj3Y.js +1745 -0
- package/dist/_chunks/PkFilePreview-DfYzaj3Y.js.map +1 -0
- package/dist/_chunks/{PkFilePreviewDialog-bcTkTcYk.js → PkFilePreviewDialog-COkwyLq6.js} +2 -2
- package/dist/_chunks/{PkFilePreviewDialog-bcTkTcYk.js.map → PkFilePreviewDialog-COkwyLq6.js.map} +1 -1
- package/dist/_chunks/{PkImageEditorDialog-FpbyhV3t.js → PkImageEditorDialog-Ceas-HZA.js} +2 -2
- package/dist/_chunks/{PkImageEditorDialog-FpbyhV3t.js.map → PkImageEditorDialog-Ceas-HZA.js.map} +1 -1
- package/dist/_chunks/{PkSelectionActions-BbfVZY0R.js → PkSelectionActions-Dl3cKb7x.js} +2 -2
- package/dist/_chunks/PkSelectionActions-Dl3cKb7x.js.map +1 -0
- package/dist/_chunks/{PkStreamingMarkdown-COSOOhCg.js → PkStreamingMarkdown-DZvLHy2l.js} +2 -2
- package/dist/_chunks/{PkStreamingMarkdown-COSOOhCg.js.map → PkStreamingMarkdown-DZvLHy2l.js.map} +1 -1
- package/dist/_chunks/{PkToolChatFile-C_gS0X1j.js → PkToolChatFile-D4ukZ9g6.js} +3 -3
- package/dist/_chunks/{PkToolChatFile-C_gS0X1j.js.map → PkToolChatFile-D4ukZ9g6.js.map} +1 -1
- package/dist/_chunks/{PkToolShowArtifact-fpFtKrZo.js → PkToolShowArtifact-wIAxyXrL.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-fpFtKrZo.js.map → PkToolShowArtifact-wIAxyXrL.js.map} +1 -1
- package/dist/_chunks/PkToolShowChart-D3E_xBJv.js +138 -0
- package/dist/_chunks/PkToolShowChart-D3E_xBJv.js.map +1 -0
- package/dist/_chunks/{PkToolShowContactForm-BAM772bm.js → PkToolShowContactForm-BhcM-Z6m.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-BAM772bm.js.map → PkToolShowContactForm-BhcM-Z6m.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-DJcL0bgw.js → PkToolShowForm-D6k7_QLF.js} +3 -3
- package/dist/_chunks/{PkToolShowForm-DJcL0bgw.js.map → PkToolShowForm-D6k7_QLF.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-GeWAMHYC.js → PkToolShowSources-Cw1ofky2.js} +2 -2
- package/dist/_chunks/{PkToolShowSources-GeWAMHYC.js.map → PkToolShowSources-Cw1ofky2.js.map} +1 -1
- package/dist/_chunks/chartFormat-B1T7y-16.js +27 -0
- package/dist/_chunks/chartFormat-B1T7y-16.js.map +1 -0
- package/dist/_chunks/{excelNumberFormat-BhQjife9.js → excelNumberFormat-CcXF_wJK.js} +101 -88
- package/dist/_chunks/excelNumberFormat-CcXF_wJK.js.map +1 -0
- package/dist/_chunks/{utils-DMvy5QRR.js → utils-C2aFWWye.js} +132 -110
- package/dist/_chunks/utils-C2aFWWye.js.map +1 -0
- package/dist/ai-elements.es.js +2939 -2882
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotEmptyState.js +1 -1
- package/dist-vue/PkChatbotInput.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotStepPayload.js +1 -1
- package/dist-vue/PkChatbotStepToolDetail.js +1 -1
- package/dist-vue/PkChatbotSteps.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/PkChatbotViewConversations.js +1 -1
- package/dist-vue/_chunks/Chart-DsBNs5rS.js +87 -0
- package/dist-vue/_chunks/Chart-DsBNs5rS.js.map +1 -0
- package/dist-vue/_chunks/{PkChart-D-K7nc0g.js → PkChart-CrZqhEpp.js} +112 -74
- package/dist-vue/_chunks/PkChart-CrZqhEpp.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbot-DVQ-Bb7n.js → PkChatbot-CBSe9MOB.js} +6 -6
- package/dist-vue/_chunks/{PkChatbot-DVQ-Bb7n.js.map → PkChatbot-CBSe9MOB.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotEmptyState-OlgewA4_.js → PkChatbotEmptyState-DfyYZXHQ.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-OlgewA4_.js.map → PkChatbotEmptyState-DfyYZXHQ.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotInput-D_I0Gf_u.js → PkChatbotInput-CBalSveL.js} +4 -4
- package/dist-vue/_chunks/{PkChatbotInput-D_I0Gf_u.js.map → PkChatbotInput-CBalSveL.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotMessages-CAXnEfXK.js → PkChatbotMessages-C2AUTqk4.js} +307 -307
- package/dist-vue/_chunks/{PkChatbotMessages-CAXnEfXK.js.map → PkChatbotMessages-C2AUTqk4.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepPayload-EBri1L10.js → PkChatbotStepPayload-Bb3Y6kuL.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-EBri1L10.js.map → PkChatbotStepPayload-Bb3Y6kuL.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-DiQEa0UV.js → PkChatbotStepToolDetail-CwOxzYOe.js} +16 -16
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-DiQEa0UV.js.map → PkChatbotStepToolDetail-CwOxzYOe.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotSteps-BgLnv2J1.js → PkChatbotSteps-FduD9X9i.js} +38 -38
- package/dist-vue/_chunks/{PkChatbotSteps-BgLnv2J1.js.map → PkChatbotSteps-FduD9X9i.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-CmjD1IXf.js → PkChatbotViewChat-jl3ZbK7H.js} +22 -22
- package/dist-vue/_chunks/{PkChatbotViewChat-CmjD1IXf.js.map → PkChatbotViewChat-jl3ZbK7H.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewConversations-CVZH5dXx.js → PkChatbotViewConversations-BtwTWqmM.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewConversations-CVZH5dXx.js.map → PkChatbotViewConversations-BtwTWqmM.js.map} +1 -1
- package/dist-vue/_chunks/{PkFilePreview-k5gEl3n8.js → PkFilePreview-CRfDEYYo.js} +701 -624
- package/dist-vue/_chunks/PkFilePreview-CRfDEYYo.js.map +1 -0
- package/dist-vue/_chunks/{PkFilePreviewDialog-DUwZPErE.js → PkFilePreviewDialog-u-0rhuRx.js} +2 -2
- package/dist-vue/_chunks/{PkFilePreviewDialog-DUwZPErE.js.map → PkFilePreviewDialog-u-0rhuRx.js.map} +1 -1
- package/dist-vue/_chunks/{PkImageEditorDialog-DQPXePae.js → PkImageEditorDialog-CjMwpb-a.js} +2 -2
- package/dist-vue/_chunks/{PkImageEditorDialog-DQPXePae.js.map → PkImageEditorDialog-CjMwpb-a.js.map} +1 -1
- package/dist-vue/_chunks/{PkStreamingMarkdown-ZasabxE0.js → PkStreamingMarkdown-7Kl_VBH-.js} +2 -2
- package/dist-vue/_chunks/{PkStreamingMarkdown-ZasabxE0.js.map → PkStreamingMarkdown-7Kl_VBH-.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolChatFile-CD26Q2xp.js → PkToolChatFile-DcNRCVXy.js} +3 -3
- package/dist-vue/_chunks/{PkToolChatFile-CD26Q2xp.js.map → PkToolChatFile-DcNRCVXy.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowArtifact-BhVd_ZQ8.js → PkToolShowArtifact-C7CxCqVO.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-BhVd_ZQ8.js.map → PkToolShowArtifact-C7CxCqVO.js.map} +1 -1
- package/dist-vue/_chunks/PkToolShowChart-DULlrMjq.js +133 -0
- package/dist-vue/_chunks/PkToolShowChart-DULlrMjq.js.map +1 -0
- package/dist-vue/_chunks/{PkToolShowContactForm-CackCDGD.js → PkToolShowContactForm-472d-SAE.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-CackCDGD.js.map → PkToolShowContactForm-472d-SAE.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-CABPsFi8.js → PkToolShowDiagram-RrqVpOaX.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-CABPsFi8.js.map → PkToolShowDiagram-RrqVpOaX.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-BStbk4Iu.js → PkToolShowForm-CgyszDEI.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowForm-BStbk4Iu.js.map → PkToolShowForm-CgyszDEI.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowImageGallery-BeeHsdTp.js → PkToolShowImageGallery-LBx9JE6p.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowImageGallery-BeeHsdTp.js.map → PkToolShowImageGallery-LBx9JE6p.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-BfUiap9U.js → PkToolShowProductList-THiH4EzZ.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-BfUiap9U.js.map → PkToolShowProductList-THiH4EzZ.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-CgEkcyRg.js → PkToolShowSources-CEqGXOOt.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSources-CgEkcyRg.js.map → PkToolShowSources-CEqGXOOt.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowVideo-CqSRnDNC.js → PkToolShowVideo-8Gi3vOer.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowVideo-CqSRnDNC.js.map → PkToolShowVideo-8Gi3vOer.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-B-qIS8qY.js → PkToolShowWebPages-xjUPdfOU.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-B-qIS8qY.js.map → PkToolShowWebPages-xjUPdfOU.js.map} +1 -1
- package/dist-vue/_chunks/chartFormat-B1T7y-16.js +27 -0
- package/dist-vue/_chunks/chartFormat-B1T7y-16.js.map +1 -0
- package/dist-vue/_chunks/{excelNumberFormat-C1sCQrOz.js → excelNumberFormat-BxRi0Y3e.js} +101 -88
- package/dist-vue/_chunks/excelNumberFormat-BxRi0Y3e.js.map +1 -0
- package/dist-vue/_chunks/{utils-KBB6SDPn.js → utils-VVbH-Liq.js} +30 -30
- package/dist-vue/_chunks/utils-VVbH-Liq.js.map +1 -0
- package/dist-vue/apps/web-component/src/composables/useChatbotAgent.d.ts +6 -6
- package/dist-vue/apps/web-component/src/composables/useSelectionActions.d.ts +14 -4
- package/dist-vue/composables.js +9 -3
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/index.js +42 -42
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +6 -0
- package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +6 -6
- package/dist-vue/packages/components/src/chat/PkChart.d.ts +8 -0
- package/dist-vue/packages/components/src/chat/PkChatbotMessages.d.ts +1 -1
- package/dist-vue/packages/components/src/chat/PkFileChart.d.ts +14 -0
- package/dist-vue/packages/components/src/chat/PkSelectionActionIconPicker.d.ts +2 -2
- package/dist-vue/packages/components/src/chat/PkSelectionAnswerCard.d.ts +6 -0
- package/dist-vue/packages/components/src/chat/PkWordPreviewRuns.d.ts +4 -1
- package/dist-vue/packages/components/src/chat/selectionActionEdits.d.ts +1 -1
- package/dist-vue/packages/components/src/chat/useChatFilePreview.d.ts +240 -0
- package/dist-vue/packages/components/src/chat/utils.d.ts +57 -5
- package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +18 -18
- package/dist-vue/packages/composable/src/useSettledSelection.d.ts +2 -2
- package/dist-vue/packages/models/src/schema/Agent.d.ts +21 -21
- package/dist-vue/packages/models/src/schema/Chart.d.ts +91 -0
- package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +6 -6
- package/dist-vue/packages/models/src/schema/SelectionAction.d.ts +11 -11
- package/dist-vue/packages/models/src/schema/SelectionActionPreview.d.ts +3 -3
- package/dist-vue/packages/models/src/schema/SpreadsheetPreview.d.ts +381 -0
- package/dist-vue/packages/models/src/schema/SubAgent.d.ts +6 -6
- package/dist-vue/packages/models/src/schema/WordPreview.d.ts +304 -0
- package/dist-vue/style.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/PkChart-CbtMRGWc.js.map +0 -1
- package/dist/_chunks/PkFilePreview-DC4iX7Yc.js +0 -1665
- package/dist/_chunks/PkFilePreview-DC4iX7Yc.js.map +0 -1
- package/dist/_chunks/PkSelectionActions-BbfVZY0R.js.map +0 -1
- package/dist/_chunks/PkToolShowChart-DZWu3Yuo.js +0 -224
- package/dist/_chunks/PkToolShowChart-DZWu3Yuo.js.map +0 -1
- package/dist/_chunks/excelNumberFormat-BhQjife9.js.map +0 -1
- package/dist/_chunks/utils-DMvy5QRR.js.map +0 -1
- package/dist-vue/_chunks/PkChart-D-K7nc0g.js.map +0 -1
- package/dist-vue/_chunks/PkFilePreview-k5gEl3n8.js.map +0 -1
- package/dist-vue/_chunks/PkToolShowChart-BQXxaPIO.js +0 -217
- package/dist-vue/_chunks/PkToolShowChart-BQXxaPIO.js.map +0 -1
- package/dist-vue/_chunks/excelNumberFormat-C1sCQrOz.js.map +0 -1
- package/dist-vue/_chunks/utils-KBB6SDPn.js.map +0 -1
package/README.md
CHANGED
|
@@ -1040,10 +1040,15 @@ question of the user's own. An action of the agent's own has a label and an inst
|
|
|
1040
1040
|
language: the menu shows it in the widget's language, or, where the author did not write that
|
|
1041
1041
|
one, in the first language its label is written in, and sends the instruction of the same
|
|
1042
1042
|
language. The menu takes the place of the **Ask** bubble of Point and ask, with the chat open and
|
|
1043
|
-
closed
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1043
|
+
closed. On a touch screen it shows too, once the selection has rested for a moment: below the
|
|
1044
|
+
text, clear of the selection's handles and of the menu the phone opens above a selection, and
|
|
1045
|
+
above that menu only when the text is on the last line of the screen. The card of an answer
|
|
1046
|
+
also tries below first there, clear of the same menu, and the field of **Ask…** stays above the
|
|
1047
|
+
keyboard. The **Ask**
|
|
1048
|
+
bubble stays on devices with a mouse or a trackpad. The menu never shows on a text in the widget,
|
|
1049
|
+
in an excluded area or touching a sensitive field, while an answer is running, while the user
|
|
1050
|
+
points, or while your page has a modal dialog open. Its rows take no focus on a click, so the text
|
|
1051
|
+
stays selected and `Cmd+C` still copies it; `Esc` or a click elsewhere closes it.
|
|
1047
1052
|
|
|
1048
1053
|
An action sends a message whose text is the action's instruction ("Explain the text I selected
|
|
1049
1054
|
in plain words."), carrying the selected text as Point and ask does. It is an ordinary turn of the
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { _ as e, b as t, g as n, o as r, r as i, s as a } from "./zod-Cty6wiWN.js";
|
|
2
|
+
// ../../packages/models/src/schema/Chart.ts
|
|
3
|
+
var o = [
|
|
4
|
+
"bar",
|
|
5
|
+
"line",
|
|
6
|
+
"pie",
|
|
7
|
+
"doughnut"
|
|
8
|
+
], s = [
|
|
9
|
+
"positive",
|
|
10
|
+
"warning",
|
|
11
|
+
"negative",
|
|
12
|
+
"critical",
|
|
13
|
+
"neutral"
|
|
14
|
+
], c = [
|
|
15
|
+
"number",
|
|
16
|
+
"percent",
|
|
17
|
+
"currency"
|
|
18
|
+
], l = {
|
|
19
|
+
maxCategories: 50,
|
|
20
|
+
maxSeries: 8,
|
|
21
|
+
maxSlices: 12,
|
|
22
|
+
maxCharts: 4
|
|
23
|
+
}, u = (e) => e === "pie" || e === "doughnut", d = 120, f = e({
|
|
24
|
+
name: t().min(1).max(d).describe("Series name, shown in the legend"),
|
|
25
|
+
values: r(n().nullable()).max(l.maxCategories).describe("One number per category, in the same order; null for none"),
|
|
26
|
+
tone: i(s).optional().describe("Only when the series means a judgement (e.g. high risk = negative): it takes that color")
|
|
27
|
+
}), p = e({
|
|
28
|
+
type: i(o).describe("bar to compare amounts, line for a trend over time, pie or doughnut for the shares of one whole"),
|
|
29
|
+
title: t().max(200).optional().describe("Short title above the chart"),
|
|
30
|
+
horizontal: a().optional().describe("bar only: categories on the vertical axis, for long labels"),
|
|
31
|
+
stacked: a().optional().describe("bar only: the series stacked into one bar per category"),
|
|
32
|
+
categories: r(t().max(d)).min(1).max(l.maxCategories, `At most ${l.maxCategories} categories: group the smallest ones.`).describe("The labels of the x axis (or of the slices), in display order"),
|
|
33
|
+
series: r(f).min(1).max(l.maxSeries, `At most ${l.maxSeries} series.`).describe("One or more named series; exactly one for pie or doughnut"),
|
|
34
|
+
valueLabel: t().max(d).optional().describe("What the numbers measure, with the unit (e.g. \"Clienti\")"),
|
|
35
|
+
categoryLabel: t().max(d).optional().describe("What the categories are (e.g. \"Fascia di rating\")"),
|
|
36
|
+
format: i(c).optional().describe("How values read: percent means 0.25 is 25%, currency is in euro")
|
|
37
|
+
}), m = p.superRefine((e, t) => {
|
|
38
|
+
let { type: n, categories: r, series: i } = e, a = (e, n) => t.addIssue({
|
|
39
|
+
code: "custom",
|
|
40
|
+
message: e,
|
|
41
|
+
path: n
|
|
42
|
+
});
|
|
43
|
+
i.forEach((e, t) => {
|
|
44
|
+
e.values.length !== r.length && a(`Series "${e.name}" has ${e.values.length} values for ${r.length} categories: give one value per category.`, [
|
|
45
|
+
"series",
|
|
46
|
+
t,
|
|
47
|
+
"values"
|
|
48
|
+
]), e.values.every((e) => e === null) && a(`Series "${e.name}" has no values: leave it out, or give its numbers.`, [
|
|
49
|
+
"series",
|
|
50
|
+
t,
|
|
51
|
+
"values"
|
|
52
|
+
]);
|
|
53
|
+
}), u(n) && (i.length !== 1 && a(`A ${n} chart has exactly one series: ${i.length} given. Use a bar chart to compare several.`, ["series"]), r.length > l.maxSlices && a(`${r.length} slices: at most ${l.maxSlices} in a ${n}. Group the smallest into one, or use a bar chart.`, ["categories"]), i[0]?.values.some((e) => e !== null && e < 0) ? a(`A ${n} chart cannot show negative values.`, [
|
|
54
|
+
"series",
|
|
55
|
+
0,
|
|
56
|
+
"values"
|
|
57
|
+
]) : i[0]?.values.some((e) => e !== null) && !i[0].values.some((e) => e !== null && e > 0) && a(`A ${n} chart needs at least one value above zero: every slice is empty.`, [
|
|
58
|
+
"series",
|
|
59
|
+
0,
|
|
60
|
+
"values"
|
|
61
|
+
]));
|
|
62
|
+
}), h = e({
|
|
63
|
+
charts: r(m).min(1).max(l.maxCharts).describe("Every chart the user asked for, one entry each (e.g. a pie and a bar chart of the same numbers)"),
|
|
64
|
+
caption: t().max(500).optional().describe("Optional note below the charts, e.g. the source")
|
|
65
|
+
}), g = {
|
|
66
|
+
maxCategories: 500,
|
|
67
|
+
maxSeries: 24
|
|
68
|
+
}, _ = p.extend({
|
|
69
|
+
categories: r(t().max(d)).min(1).max(g.maxCategories),
|
|
70
|
+
series: r(f.extend({
|
|
71
|
+
name: t().max(d),
|
|
72
|
+
values: r(n().nullable()).max(g.maxCategories)
|
|
73
|
+
})).min(1).max(g.maxSeries)
|
|
74
|
+
}), v = e({
|
|
75
|
+
chart: _.optional(),
|
|
76
|
+
colors: r(t()).optional(),
|
|
77
|
+
legend: i([
|
|
78
|
+
"top",
|
|
79
|
+
"bottom",
|
|
80
|
+
"left",
|
|
81
|
+
"right"
|
|
82
|
+
]).optional(),
|
|
83
|
+
title: t().max(200).optional()
|
|
84
|
+
});
|
|
85
|
+
export { h as n, u as r, v as t };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=Chart-1vt0m6l_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chart-1vt0m6l_.js","names":["z.object","z.string","z.array","z.number","z.enum","z.boolean","object","string","number","array","_enum","boolean","CHART_TYPES","CHART_TONES","CHART_FORMATS","CHART_LIMITS","isRoundChart","type","LABEL_MAX","ChartSeriesSchema","ChartFieldsSchema","ChartSchema","chart","issue","ctx","series","s","categories","i","v","ShowChartInputSchema","FILE_CHART_LIMITS","FileChartSchema","PreviewChartSchema"],"sources":["../../../../packages/models/src/schema/Chart.ts"],"sourcesContent":["import * as z from 'zod'\nimport { AgentBuiltInTool } from './Agent'\n\n// A chart as the model describes it (spec `chat-charts.md`): categories and\n// named series of numbers, no colors or code. `showChart` draws it in the\n// chat; the Excel and Word files the agent creates write the same shape as a\n// native Office chart.\n\nexport const CHART_TYPES = ['bar', 'line', 'pie', 'doughnut'] as const\nexport type ChartType = (typeof CHART_TYPES)[number]\n\n/** The meaning a series' color carries, drawn with the semantic colors. */\nexport const CHART_TONES = [\n 'positive',\n 'warning',\n 'negative',\n 'critical',\n 'neutral',\n] as const\nexport type ChartTone = (typeof CHART_TONES)[number]\n\nexport const CHART_FORMATS = ['number', 'percent', 'currency'] as const\nexport type ChartFormat = (typeof CHART_FORMATS)[number]\n\nexport const CHART_LIMITS = {\n maxCategories: 50,\n maxSeries: 8,\n /** Slices of a pie or a doughnut: more do not read. */\n maxSlices: 12,\n /** Charts in one `showChart` call. */\n maxCharts: 4,\n} as const\n\n/**\n * The agent can draw a chart in the chat: with `showChart`, or with the\n * Mermaid XY chart of `showDiagram` when it has not got the first. What the\n * \"Make a chart\" selection action needs.\n */\nexport const hasChatChartTool = (\n disabledTools: readonly AgentBuiltInTool[],\n): boolean =>\n !disabledTools.includes(AgentBuiltInTool.ShowChart) ||\n !disabledTools.includes(AgentBuiltInTool.ShowDiagram)\n\n/** A pie or a doughnut: one series, its values the slices. */\nexport const isRoundChart = (type: ChartType): boolean =>\n type === 'pie' || type === 'doughnut'\n\n/** Labels short enough for a legend, an axis and a slice. */\nconst LABEL_MAX = 120\n\nexport const ChartSeriesSchema = z.object({\n name: z\n .string()\n .min(1)\n .max(LABEL_MAX)\n .describe('Series name, shown in the legend'),\n values: z\n .array(z.number().nullable())\n .max(CHART_LIMITS.maxCategories)\n .describe('One number per category, in the same order; null for none'),\n tone: z\n .enum(CHART_TONES)\n .optional()\n .describe(\n 'Only when the series means a judgement (e.g. high risk = negative): it takes that color',\n ),\n})\nexport type ChartSeries = z.infer<typeof ChartSeriesSchema>\n\n/**\n * The fields of a chart, without the checks across them: the schema a tool\n * extends before {@link refineChart} adds those checks.\n */\nexport const ChartFieldsSchema = z.object({\n type: z\n .enum(CHART_TYPES)\n .describe(\n 'bar to compare amounts, line for a trend over time, pie or doughnut for the shares of one whole',\n ),\n title: z\n .string()\n .max(200)\n .optional()\n .describe('Short title above the chart'),\n horizontal: z\n .boolean()\n .optional()\n .describe('bar only: categories on the vertical axis, for long labels'),\n stacked: z\n .boolean()\n .optional()\n .describe('bar only: the series stacked into one bar per category'),\n // The limits in the schema, so the model reads them before it writes\n categories: z\n .array(z.string().max(LABEL_MAX))\n .min(1)\n .max(\n CHART_LIMITS.maxCategories,\n `At most ${CHART_LIMITS.maxCategories} categories: group the smallest ones.`,\n )\n .describe(\n 'The labels of the x axis (or of the slices), in display order',\n ),\n series: z\n .array(ChartSeriesSchema)\n .min(1)\n .max(\n CHART_LIMITS.maxSeries,\n `At most ${CHART_LIMITS.maxSeries} series.`,\n )\n .describe('One or more named series; exactly one for pie or doughnut'),\n valueLabel: z\n .string()\n .max(LABEL_MAX)\n .optional()\n .describe('What the numbers measure, with the unit (e.g. \"Clienti\")'),\n categoryLabel: z\n .string()\n .max(LABEL_MAX)\n .optional()\n .describe('What the categories are (e.g. \"Fascia di rating\")'),\n format: z\n .enum(CHART_FORMATS)\n .optional()\n .describe(\n 'How values read: percent means 0.25 is 25%, currency is in euro',\n ),\n})\n\n/**\n * The checks JSON Schema cannot state, worded for the model that wrote the\n * chart: it reads the message and calls again.\n */\nexport const refineChart = (\n chart: z.infer<typeof ChartFieldsSchema>,\n ctx: z.RefinementCtx,\n) => {\n const { type, categories, series } = chart\n const issue = (message: string, path: (string | number)[]) =>\n ctx.addIssue({ code: 'custom', message, path })\n series.forEach((s, i) => {\n if (s.values.length !== categories.length) {\n issue(\n `Series \"${s.name}\" has ${s.values.length} values for ${categories.length} categories: give one value per category.`,\n ['series', i, 'values'],\n )\n }\n if (s.values.every((v) => v === null)) {\n issue(\n `Series \"${s.name}\" has no values: leave it out, or give its numbers.`,\n ['series', i, 'values'],\n )\n }\n })\n if (isRoundChart(type)) {\n if (series.length !== 1) {\n issue(\n `A ${type} chart has exactly one series: ${series.length} given. Use a bar chart to compare several.`,\n ['series'],\n )\n }\n if (categories.length > CHART_LIMITS.maxSlices) {\n issue(\n `${categories.length} slices: at most ${CHART_LIMITS.maxSlices} in a ${type}. Group the smallest into one, or use a bar chart.`,\n ['categories'],\n )\n }\n if (series[0]?.values.some((v) => v !== null && v < 0)) {\n issue(`A ${type} chart cannot show negative values.`, [\n 'series',\n 0,\n 'values',\n ])\n } else if (\n series[0]?.values.some((v) => v !== null) &&\n !series[0].values.some((v) => v !== null && v > 0)\n ) {\n issue(\n `A ${type} chart needs at least one value above zero: every slice is empty.`,\n ['series', 0, 'values'],\n )\n }\n }\n}\n\nexport const ChartSchema = ChartFieldsSchema.superRefine(refineChart)\nexport type Chart = z.infer<typeof ChartSchema>\n\n/**\n * The input of `showChart`: every chart the user asked for in one call. A\n * presentation tool ends the turn, and a model that calls one chart at a\n * time (GPT-6.1 Sol, asked for a pie and a bar chart, drew the pie only)\n * would never draw the second.\n */\nexport const ShowChartInputSchema = z.object({\n charts: z\n .array(ChartSchema)\n .min(1)\n .max(CHART_LIMITS.maxCharts)\n .describe(\n 'Every chart the user asked for, one entry each (e.g. a pie and a bar chart of the same numbers)',\n ),\n caption: z\n .string()\n .max(500)\n .optional()\n .describe('Optional note below the charts, e.g. the source'),\n})\nexport type ShowChartInput = z.infer<typeof ShowChartInputSchema>\n\n/**\n * A chart read from an Excel or a Word file holds as many points as the file\n * does: a year of days is a line chart. Past these the viewer leaves it\n * undrawn.\n */\nexport const FILE_CHART_LIMITS = {\n maxCategories: 500,\n maxSeries: 24,\n} as const\n\n/**\n * The chart the viewer draws from a file (spec `chat-charts.md`, F4): the\n * fields of {@link ChartFieldsSchema}, as many points as\n * {@link FILE_CHART_LIMITS} allows, and a series the file leaves unnamed.\n */\nexport const FileChartSchema = ChartFieldsSchema.extend({\n categories: z\n .array(z.string().max(LABEL_MAX))\n .min(1)\n .max(FILE_CHART_LIMITS.maxCategories),\n series: z\n .array(\n ChartSeriesSchema.extend({\n /** Empty where the file names none: the viewer numbers it. */\n name: z.string().max(LABEL_MAX),\n values: z\n .array(z.number().nullable())\n .max(FILE_CHART_LIMITS.maxCategories),\n }),\n )\n .min(1)\n .max(FILE_CHART_LIMITS.maxSeries),\n})\nexport type FileChart = z.infer<typeof FileChartSchema>\n\n/**\n * A chart of a file in the viewer: drawn with the file's colors and legend,\n * or, for a kind the chat cannot draw (area, scatter, a combination), a\n * placeholder named by its title.\n */\nexport const PreviewChartSchema = z.object({\n chart: FileChartSchema.optional(),\n /** `#rrggbb`: one per series, or one per slice of a pie or a doughnut. */\n colors: z.array(z.string()).optional(),\n /** Where the file puts the legend; none when it has none. */\n legend: z.enum(['top', 'bottom', 'left', 'right']).optional(),\n /** The title of a chart the viewer does not draw. */\n title: z.string().max(200).optional(),\n})\nexport type PreviewChart = z.infer<typeof PreviewChartSchema>\n"],"mappings":";;AAQA,IAAaY,IAAc;CAAC;CAAO;CAAQ;CAAO;AAAU,GAI/CC,IAAc;CACvB;CACA;CACA;CACA;CACA;AACJ,GAGaC,IAAgB;CAAC;CAAU;CAAW;AAAU,GAGhDC,IAAe;CACxB,eAAe;CACf,WAAW;CAEX,WAAW;CAEX,WAAW;AACf,GAcaC,KAAgB,MACzBC,MAAS,SAASA,MAAS,YAGzBC,IAAY,KAELC,IAAoBnB,EAAS;CACtC,MAAMC,EACM,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAIiB,CAAS,CAAC,CACd,SAAS,kCAAkC;CAChD,QAAQh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